'use strict';
/**
 * Created by zhouzhongyuan on 2016/1/11.
 */
$app.model(function (remote) {
  return {
    validation  : {
      username: {
        required: true,
        msg     : '请输入用户名'
      },
      password: [{
        required: true,
        msg     : "请输入密码"
      }, {
        fn: 'validatePass'
      }]
    },
    validatePass: function (value, attr, data) {
      var model = this;
      if (data.username && data.password) {
        remote.api("user.auth.login", data, function ($data) {
          model.trigger('validated:valid');
        });
        return '正在验证密码...';
      }
    }
  };
});